package cn.sunline.dreamvalue.utils;

import java.util.HashMap;
import java.util.Map;
/**
 * @Description: 模拟流程上下文工具类
 * @Package: flow-demo
 * @email: Hacker_lsr@126.com
 * @author: lishirui
 **/
public class FlowContext {
    private FlowContext(){}

    private static Map<String , Object> map=new HashMap<>();

    public static void putInstance(String key, Object value){
        if (key!=null && !key.isEmpty() && value!=null){
            if (!map.containsKey(key)){
                map.put(key,value);
            }
        }
    }

    public static Object getInstance(String key){
        return map.get(key);
    }

    public static void update(String key,Object o){
        if (null!=getInstance(key)){
            map.remove(key);
            putInstance(key,o);
        }
        putInstance(key,o);
    }

}

